package com.zyq.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zyq.common.entity.AclUser;
import com.zyq.security.annotation.RequiresPermissions;
import com.zyq.system.service.AclUserService;
import com.zyq.common.vo.Result;
import com.zyq.system.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/user")
public class AclUserController {
    @Autowired
    private AclUserService aclUserService;
    @RequestMapping("/getUserByPage/{currentPage}/{pageSize}")
    // 用户管理分页查询
    public Result<IPage<AclUser>> getUserByPage(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody UserVo userVo){
        return aclUserService.getUserByPage(currentPage,pageSize,userVo);
    }

    @RequestMapping("/getUserInfo/{username}")
    public Result<AclUser> getUserInfo(@PathVariable("username") String username){
        Result<AclUser> userInfoByUsername = aclUserService.getUserInfoByUsername(username);
        return userInfoByUsername;
    }
    @GetMapping("/info")
    public Result<AclUser> getInfo(){
        System.out.println("==========================");
        return aclUserService.getInfoFromToken();
    }

    @RequestMapping("/list")
    @RequiresPermissions("user:list")
    public Result<String> list(){
        System.out.println("-------用户查询成功-------");
        return new Result<>(200,"查询成功","user:list");
    }

    @RequestMapping("/delete")
    @RequiresPermissions("user:delete")
    public Result<String> delete(){
        System.out.println("-------用户删除成功-------");
        return new Result<>(200,"删除成功","user:remove");
    }
}
